using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Diagnostics;

namespace PSE.Deployment.SetupBase.Commands
{
    public class Messages
    {
        #region Messages

        //public static string WriteHeader()
        //{
        //    StringBuilder header = new StringBuilder();

        //    header.AppendLine("*************************************************************");
        //    header.Append("BM&FBOVESPA Setup, Version ");
        //    header.AppendLine(Assembly.GetExecutingAssembly().GetName().Version.ToString());
        //    header.AppendLine("*************************************************************");
        //    header.AppendLine();

        //    return header.ToString();
        //}

        //public static string WriteFooter()
        //{
        //    StringBuilder footer = new StringBuilder();
        //    footer.AppendLine();
        //    footer.AppendFormat("If you would like more help, type \"{0}.exe /help\"", Assembly.GetExecutingAssembly().GetName().Name);

        //    return footer.ToString();
        //}

        #endregion

        #region ErrorMessages

        public static void WriteError(string error)
        {
            StringBuilder errorMessage = new StringBuilder();
            //errorMessage.Append(WriteHeader());
            errorMessage.Append("Error: ");
            errorMessage.AppendLine(error);
            //errorMessage.AppendLine(WriteFooter());
            System.Console.Write(errorMessage.ToString());
        }

        public static void WriteFailMessage(Exception ex)
        {
            StringBuilder failMessage = new StringBuilder();
            //failMessage.Append(WriteHeader());
            failMessage.Append("Failed: ");
            failMessage.AppendLine(ex.Message);
            //failMessage.AppendLine(WriteFooter());
            System.Console.Write(failMessage.ToString());

            System.Diagnostics.EventLog.WriteEntry("PSE Setup", ex.ToString(), EventLogEntryType.Error);
        }

        public static void InvalidArgumentError(string error)
        {
            WriteError(error);
        }

        public static void CommandSyntaxError(string command)
        {
            string error = "Unrecognized command '" + command + "' specified.";
            WriteError(error);
        }

        public static void NoFileSpecifiedError()
        {
            string error = "A file name must be specified.";
            WriteError(error);
        }

        public static void FileDoesNotExistsError()
        {
            string error = "The specified file does not exists. Please check the syntax and try again.";
            WriteError(error);
        }
        
        public static void NoArgsSyntaxError()
        {
            string error = "No command specified.";
            WriteError(error);
        }

        public static void InvalidHelpCommand()
        {
            string error = "Invalid help command.";
            WriteError(error);
        }

        public static void SystemNotInstalled()
        {
            string error = "The system is not installed.";
            WriteError(error);
        }

        public static void SystemInstalled()
        {
            string error = "The system is already installed.";
            WriteError(error);
        }

        public static void InvalidOptionError(string option)
        {
            string error = "The option '" + option + "' specified is invalid.";
            WriteError(error);
        }

        #endregion
    }
}
